package com.ruoyi.web.controller.game;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysMember;
import com.ruoyi.system.service.ISysMemberService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2024-10-08
 */
@Api(value = "小助手会员")
@RestController
@RequestMapping("/system/member")
public class SysMemberController extends BaseController
{
    @Autowired
    private ISysMemberService sysMemberService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:member:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysMember sysMember)
    {
        startPage();
        List<SysMember> list = sysMemberService.selectSysMemberList(sysMember);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:member:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysMember sysMember)
    {
        List<SysMember> list = sysMemberService.selectSysMemberList(sysMember);
        ExcelUtil<SysMember> util = new ExcelUtil<SysMember>(SysMember.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation("获得会员信息")
    @PreAuthorize("@ss.hasPermi('system:member:query')")
    @GetMapping()
    public AjaxResult getInfo(@RequestParam Long id)
    {
        return success(sysMemberService.selectSysMemberById(id));
    }

    @GetMapping(value = "/{userId}")
    public AjaxResult getUserInfo(@PathVariable("userId") Long id)
    {
        return success(sysMemberService.selectSysMemberByUserId(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:member:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysMember sysMember)
    {
        return toAjax(sysMemberService.insertSysMember(sysMember));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:member:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysMember sysMember)
    {
        return toAjax(sysMemberService.updateSysMember(sysMember));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:member:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysMemberService.deleteSysMemberByIds(ids));
    }
}
